// dungeons_and_princesses_gui.cpp
//
// Created by Raquel Rhodes on 11/6
// Edited by Christopher Bowlsby
// Last updated on 11/23

#include "dungeons_and_princesses_gui.h"
#include "ui_dungeons_and_princesses_gui.h"
#include "GuiInterface.h"
#include <QTGUI/QMessageBox>
#include <QTGUI/QDialog>
#include <QGraphicsObject>
#include <iostream>
#include <string>
#include <cstdlib>
#include <QtGui/QtGui>
#ifndef QT_NO_OPENGL
#include <QtOpenGL/QtOpenGL>
#endif


// constructor
Dungeons_and_Princesses_gui::Dungeons_and_Princesses_gui(int index, QWidget *parent) :
    QWidget(parent), ui(new Ui::Dungeons_and_Princesses_gui) {

    ui->setupUi(this);

    //initialize main gui interface
    ui->graphicsView_MainWindow->setStyleSheet("background-image: url(./Data/castle-wall1.png);");
    ui->graphicsView_Room->setStyleSheet("background-image: url(./Data/R1.png);");

    //ui->pushButton_surprise_0->setIcon();

    if(index == 1) {
        ui->label_characterImage->setStyleSheet("background-image: url(./Data/warrior.png);");
    }else if(index == 2) {
        ui->label_characterImage->setStyleSheet("background-image: url(./Data/wizard.png);");
    }else if(index == 3) {
        ui->label_characterImage->setStyleSheet("background-image: url(./Data/ranger.png);");
    }

    ui->label_characterImage->setScaledContents(true);
}


// destructor
Dungeons_and_Princesses_gui::~Dungeons_and_Princesses_gui()
{
    delete ui;
}


// allocates a pointer to the GuiInterface object so that it can be accessed
void Dungeons_and_Princesses_gui::getInterfaceInstance(GuiInterface *guiIf)
{
    intface = guiIf;
}

void Dungeons_and_Princesses_gui::on_pushButton_character_clicked()
{
    //This is supposed to show message:  Character's Stats
    //QMessageBox::information(this, tr("Shows Character Stats"), tr("Armor, Weapons, Attacks, etc."), tr("OK"));

    intface->somethingHappened("Shows Character Stats");
 }

void Dungeons_and_Princesses_gui::on_pushButton_N_clicked()
{
    //This will lead to room in N-direction and will update
    //roomWidget, roomDescription, and N,S,E,W buttons
    // QMessageBox::information(this, tr("North"), tr("Will move to room in North direction"), tr("OK"));

    intface->somethingHappened("move north");
}

void Dungeons_and_Princesses_gui::on_pushButton_W_clicked()
{
    //This will lead to room in W-direction and will update
    //roomWidget, roomDescription, and N,S,E,W buttons
    //QMessageBox::information(this, tr("West"), tr("Will move to room in West direction"), tr("OK"));

    intface->somethingHappened("move west");
}

void Dungeons_and_Princesses_gui::on_pushButton_S_clicked()
{
    //This will lead to room in S-direction and will update
    //roomWidget, roomDescription, and N,S,E,W buttons
    //QMessageBox::information(this, tr("South"), tr("Will move to room in South direction"), tr("OK"));

    intface->somethingHappened("move south");
}

void Dungeons_and_Princesses_gui::on_pushButton_E_clicked()
{
    //This will lead to room in E-direction and will update
    //roomWidget, roomDescription, and N,S,E,W buttons
    //QMessageBox::information(this, tr("East"), tr("Will move to room in North direction"), tr("OK"));

    intface->somethingHappened("move east");
}

/*void Dungeons_and_Princesses_gui::on_pushButton_potions_clicked()
{
    //Show popup of inventory
    QMessageBox::information(this, tr("Backpack Stuff"),
                             tr("Will show inventory - Dora's Backpack, Backpack"), tr("OK"));
}

void Dungeons_and_Princesses_gui::on_pushButton_textInput_clicked()
{
    //Reserved for later use if time permits
    QMessageBox::information(this, tr("Text Input"),
                             tr("This will be used for text input purposes"), tr("OK"));
}*/




//Game updates
void Dungeons_and_Princesses_gui::setRoomImage(std::string roomImg)
{
    //Switch Image()
    QString roomImgText = QString::fromStdString(roomImg);
    ui->graphicsView_Room->setStyleSheet(roomImgText);
    update();

}//setRoomImage

void Dungeons_and_Princesses_gui::setTextDesc(QString roomDesc)
{
    ui->textBrowser->clear();
    ui->textBrowser->setText(roomDesc);
    update();

}//setTextDesc

void Dungeons_and_Princesses_gui::setDirections(QString dirText)
{
    ui->textBrowser->setText(dirText);
    update();

   /* QString northText = QString::fromStdString(north);
    northText.append("\n");
    QString southText = QString::fromStdString(south);

    QString eastText = QString::fromStdString(east);
    QString westText = QString::fromStdString(west);

    ui->label_3_textMessages->setText(northText);
    ui->label_3_textMessages->setText(southText);
    ui->label_3_textMessages->setText(eastText);
    ui->label_3_textMessages->setText(westText);
*/
}//setDirections


// updates the gui when called
void Dungeons_and_Princesses_gui::update() {
    ui->graphicsView_MainWindow->update();
}
